<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
                xmlns:ui="http://java.sun.com/jsf/facelets"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:p="http://primefaces.prime.com.tr/ui"
                xmlns:f="http://java.sun.com/jsf/core"
                xmlns:c="http://java.sun.com/jsp/jstl/core"
                template="/template/StakeholderTemplate.xhtml">

    <ui:define name="contentInsert">
          <h3>Modify Selected Show</h3>
                <h:form id="showUpdateForm">
                    <p:panel id="panel" >
                        <hr/>
                        <h2>Event Information: </h2>
                        <hr/>
                        <h:panelGrid columns="1" border="0">
                            <p:column>
                                <font style="font-weight: bold">Stakeholder:</font>
                                <br/>
                                <h:outputText value = "#{stakeholderPerformanceMB.stakeholderName}" />
                            </p:column>
                            <br/>
                            <p:column>
                                <font style="font-weight: bold">Event:</font>
                                <br/>
                                <h:outputText value = "#{stakeholderPerformanceMB.selectedEvent}" />
                            </p:column>
                        </h:panelGrid>
                        <h:inputHidden value = "#{stakeholderPerformanceMB.selectedEventId}" />
                        <hr/>
                        
                            <p:dataTable value="#{stakeholderPerformanceMB.getAllShow()}" var="shows"
                                         onRowSelectUpdate="showUpdateForm" selectionMode="single"
                                         selection="#{stakeholderPerformanceMB.showHelper}" 
                                         rowSelectListener="#{stakeholderPerformanceMB.updateSelectedShowFields()}"
                                         styleClass="order-table" paginator="true" rows="5"
                                         >

                                <p:column>
                                    <f:facet name="header">Show ID</f:facet>
                                    <h:outputText id="showId" value="#{shows.id}" />
                                </p:column>

                                <p:column>
                                    <f:facet name="header">Timing</f:facet>
                                    <h:outputText id="showTiming" value="#{shows.timing}" />
                                </p:column>

                                <p:column>
                                    <f:facet name="header">Venue</f:facet>         
                                    <h:outputText id="eventVenue" value="#{shows.venue}" />
                                </p:column>

                            </p:dataTable> 
                        
                        <hr/>
                    </p:panel>

                    <h3>Click on a row above to edit a show</h3>
                    <p:panel>
                        <p:ajaxStatus style="width:16px;height:16px;">
                            <f:facet name="start">
                                <h:graphicImage value="http://www.primefaces.org:8080/showcase/design/ajaxloading.gif" />
                            </f:facet>
                            <f:facet name="complete">
                                <h:outputText value="" />
                            </f:facet>
                        </p:ajaxStatus>
                        <p:messages />
                        <h:panelGrid columns="2" border="0">
                            <h:outputText value="Show Id: "  />  
                            <h:outputText value="#{stakeholderPerformanceMB.selectedShowId}"/>
                            Venue
                            <p:panel>
                                <h:selectOneMenu style="width: 260px" value="#{stakeholderPerformanceMB.selectedVenue}" requiredMessage="Venue is required!" required="true">
                                    <f:selectItem itemLabel="" itemValue= ""/>
                                    <f:selectItems value="#{userPerformanceMB.getAllActiveVenues()}"></f:selectItems>
                                </h:selectOneMenu>
                            </p:panel>
                            Date 
                            <p:panel>
                                <p:calendar value="#{stakeholderPerformanceMB.selectedDate}" mindate="#{stakeholderPerformanceMB.findingMinDate()}" maxdate="#{stakeholderPerformanceBean.findingMaxDate()}" pattern="dd/MM/yyyy" required="true" requiredMessage="Date is required!"/>
                            </p:panel>
                            Time
                            <p:panel>
                                <p:spinner size="2" maxlength="2" min="00" max="23" id="hour" value="#{stakeholderPerformanceMB.selectedHour}" />
                                <p:spinner size="2" maxlength="2" min="00" max="59" id="minute" value="#{stakeholderPerformanceMB.selectedMinute}" />    
                                <h:outputText value = " (in hh:mm format)"/>
                            </p:panel><br/>
                            Show layout:

                            <p:graphicImage id="venueLayout" value="./../../#{stakeholderPerformanceMB.selectedShowLayout}" width="100" height="100"/>
                            
                            <h:outputText value="Upload Image: "/><br/><br/>
                            <h:form enctype="multipart/form-data" prependId="false">
                                <p:fileUpload fileUploadListener="#{photoManagedBean.handleEventPhotoUpload}" multiple="false" label="Browse" auto="true" allowTypes="*.jpg;*.png;*.gif;" description="Images" update="showUpdateForm:pic" />
                            </h:form>


                            <br/>
                            <p:graphicImage id="pic" value="#{photoManagedBean.photoFilePath}" height="100"
                                            width="100"/><br/>
                        </h:panelGrid>
                      
                        <h:commandButton id="submitEvent" value="Modify" onclick="if (!confirm('Are you sure you want to modify this show?')) return false"
                                         action="#{stakeholderPerformanceMB.changeShow(event)}" >
                             <f:setPropertyActionListener target="#{stakeholderPerformanceMB.selectedShowLayout}" value="#{photoManagedBean.photoFilePath}" />
                         </h:commandButton>
                    </p:panel>
                </h:form>
                 </ui:define>
</ui:composition>


